Skip to content

截图并保存成文件 - Capture

函数简介

抓取指定区域的图像并保存为文件,图片大小为 x2-x1, y2-y1。

接口名称

Capture

DLL调用

int Capture(long ola, int x1, int y1, int x2, int y2, string file);

参数说明

参数名类型说明
ola长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
x1整数型区域的左上X坐标
y1整数型区域的左上Y坐标
x2整数型区域的右下X坐标
y2整数型区域的右下Y坐标
file字符串保存的文件名,支持 .bmp、.png、.jpg 格式,使用相对路径时保存在SetPath设置的目录下

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 截取绑定窗口客户区
long imgPtr = ola.Capture(0, 0, 0, 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
// 截取绑定窗口客户区
long imgPtr = ola.Capture(0, 0, 0, 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
# 截取绑定窗口客户区
imgPtr = ola.Capture(0, 0, 0, 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
// 截取绑定窗口客户区
long imgPtr = ola.Capture(0, 0, 0, 0);
cpp
var ola = com("OlaPlug.OlaSoft")
// 截取绑定窗口客户区
var imgPtr = ola.Capture(0, 0, 0, 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
' 截取绑定窗口客户区
imgPtr = ola.Capture(0, 0, 0, 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
' 截取绑定窗口客户区
imgPtr = ola.Capture(0, 0, 0, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
// 截取绑定窗口客户区
var imgPtr = ola.Capture(0, 0, 0, 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
// 截取绑定窗口客户区
长整数 imgPtr = ola.Capture(0, 0, 0, 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
// 截取绑定窗口客户区
long imgPtr = ola.Capture(0, 0, 0, 0);

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long imgPtr = Capture(instance, 0, 0, 0, 0);
csharp
long instance = CreateCOLAPlugInterFace();
long imgPtr = Capture(instance, 0, 0, 0, 0);
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
imgPtr = Capture(instance, 0, 0, 0, 0)

返回值

整数型:1 成功,0 失败。

注意事项

  • 文件后缀名决定保存格式。
  • 保存前请确保目标目录存在。